home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Add-ons
/
Resourceror ƒ
/
BTMP.c
next >
Wrap
Text File
|
1989-11-19
|
4KB
|
96 lines
/* ========================================================================≠===========≠=============== *
file: BTMP.c
version: 1.00.00
date: 11.20.89
history: m_o 11.20.89
* ------------------------------------------------------------------------+-----------+--------------- *
Copyright © 1989, Michael Ogawa — All Rights Reserved.
May not be redistributed for commercial purposes. May not be
redistributed if altered in any way, or without accompanying
documents. May be freely distributed on electronic bulletin boards
provided no additional charges above the board’s standard connect
charges are imposed. May be freely distributed by non-profit
organizations on disk provided that any charges for the distribution
disk does not exceed actual disk, labelling materials, reproduction,
and shipping charges incurred by the organization.
This software is provided “as is”, with no warranties, either express
or implied, being made regarding its fitness for any particular
purpose.
* ========================================================================≠===========≠=============== */
#include "BTMP.h"
/* constants ==============================================================≠===========≠=============== */
#ifndef NULL
#define NULL 0L
#endif NULL
#ifndef kLockStateFlag
#define kLockStateFlag 0x80
/* The constants kResourcStateFlag, kPurgeStateFlag, and kLockStateFlag
are bit flags for the master pointer flags of a handle. They are used to
set or determine whether a relocatable block is to a resource, is
purgeable, or is locked. */
/* m_o 07.17.89 */
#endif kLockStateFlag
/* entry points ===========================================================≠===========≠=============== */
void PlotPBitMap(const Rect *r, TBTMPPtr pTheBitMap, short mode)
/* Analagous to PlotIcon except that you pass a pointer to a BTMP instead
of a handle to an ICON. Mode specifies the transfer mode to use which can
be any of the source transfer modes. This routine assumes that the handle
to the BTMP is locked. */
/* mps 06.22.89/m_o 11.20.89 */
{
GrafPtr gptr;
GetPort(&gptr);
CopyBits(pTheBitMap, &gptr->portBits,
&pTheBitMap->bounds, r, mode, NULL);
}
/* ------------------------------------------------------------------------+-----------+--------------- */
char LockBitMap(TBTMPHndl hTheBitMap)
/* LockBitMap() locks the BTMP specified by hTheBitMap and sets the
map.baseAddr field to point to the map.bitImage field of the BTMP. The
function's return value is the original value of the byte that contains
the flags of the master pointer for the given handle (as returned by
HGetState()).
Warning: If the handle is not locked on entry then the OS routine
MoveHHi() is called before locking the handle. Therefore, this routine may
move or purge blocks in the heap. */
/* m_o 11.20.89 */
{
char origState;
TBTMPPeek pkMyBitMap;
if (!((origState = HGetState((Handle)hTheBitMap)) & kLockStateFlag)) {
MoveHHi((Handle)hTheBitMap);
HLock((Handle)hTheBitMap);
}
pkMyBitMap = (TBTMPPeek)*hTheBitMap;
pkMyBitMap->map.baseAddr = (Ptr)pkMyBitMap->image;
return(origState);
}
/* ------------------------------------------------------------------------+-----------+--------------- */
void PlotBitMap(const Rect *r, TBTMPHndl hTheBitMap, short mode)
/* Analagous to PlotIcon but it works with BTMPs, not ICONs. Mode
specifies the transfer mode to use which can be any of the source transfer
modes. */
/* mps 06.22.89/m_o 11.20.89 */
{
char origState;
origState = LockBitMap(hTheBitMap);
PlotPBitMap(r, *hTheBitMap, mode);
(*hTheBitMap)->baseAddr = NULL;
HSetState((Handle)hTheBitMap, origState);
}